#ifndef _BASEMACRO_H
#define _BASEMACRO_H
//////////////////////////////////////////////////////////////////////////
//#include "QOsDefine.h"
//////////////////////////////////////////////////////////////////////////

#define QSUCCESS	0
#define QERROR	-1

#define LOWORD(l)           ((QWORD)(l))
#define HIWORD(l)           ((QWORD)(((QDWORD)(l) >> 16) & 0xFFFF))

#define MAKEWORD(a, b)      ((QWORD)(((QBYTE)(a)) | ((QWORD)((QBYTE)(b))) << 8))
#define MAKELONG(a, b)      ((QLONG)(((QWORD)(a)) | ((QDWORD)((QWORD)(b))) << 16))
#define MAKEDWORD(L8,L16,H8,H16)  ((L8) + ((L16) << 8) + ((H8) << 16) + ((H16) << 24))   


#ifndef ABS
#define ABS( a )     ( (a) < 0 ? -(a) : (a) )
#define QABS ABS
#endif

#ifndef MIN
#define MIN( a, b ) ( ( a < b ) ? a : b )
#define QMIN MIN
#endif

#ifndef MAX
#define MAX( a, b ) ( ( a > b ) ? a : b )
#define QMAX MAX
#endif


#define DELETE(pObj)   if( pObj != NULL ) { delete pObj ; pObj = NULL ;}

// #define Q_GETALPHA(rgb)      ((rgb) >> 24 & 0xff)
// #define Q_GETRED(rgb)        (((rgb) >> 16) & 0xff)
// #define Q_GETGREEN(rgb)      (((rgb) >> 8) & 0xff)
// #define Q_GETBLUE(rgb)       ((rgb) & 0xff)
// #define QRGBA(r, g, b, a)   ((QCOLOR) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
// 
// #define QRGB(r,g,b)          ((QCOLOR)(((QBYTE)(r)|((QWORD)((QBYTE)(g))<<8))|(((QDWORD)(QBYTE)(b))<<16)))
// #define Q_GetRValue24(rgb)      ((QBYTE)(rgb))
// #define Q_GetGValue24(rgb)      ((QBYTE)(((QWORD)(rgb)) >> 8))
// #define Q_GetBValue24(rgb)      ((QBYTE)((rgb)>>16))


#define DELETE_SINGLEPTR(x) \
	do { \
	if(x){ \
	delete (x); \
	(x) = NULL; \
	}\
	} while(0)

#define DELETE_MULTIPTR(x) \
	do { \
	if(x){ \
	delete[] (x); \
	(x) = NULL; \
	}\
	} while(0)

// #ifndef ASSERT
// #define ASSERT(X) assert(X)
// #endif //ASSERT




/////////////////		system define	//////////////////////
#ifdef _UNICODE
	#define STRCPY  wcscpy
	#define STRCAT	wcscat
	#define STRLEN(a)	wcslen((wchar_t*)a)
	#define STRCMP(a,b)	wcscmp((const wchar_t *)a,(const wchar_t *)b)
	#define STRNCPY	COsUtil::wcsncpy
	#define ITOA _itow
	#define ATOI _wtoi
#else
/*
	#define STRCPY	strcpy
	#define STRCAT	strcat
	#define STRLEN	strlen
	#define STRCMP	strcmp
	#define ITOA _itoa
	#define ATOI atoi
*/
#endif

//#define CSTRLEN	strlen
#define MEMCPY	memcpy
#define MEMSET	memset

//////////////////////////////////////////////////////////////////////////
#endif //_BASEMACRO_H
